home *** CD-ROM | disk | FTP | other *** search
- Path: newsserver.rdcs.Kodak.COM!usenet
- From: Roman Fietze <fietze@ag01.kodak.COM>
- Newsgroups: comp.object,comp.lang.c++,comp.realtime,comp.dcom.telecom.tech,comp.arch.embedded
- Subject: Re: Can OO be successful in real-time embedded systems?
- Date: Wed, 17 Apr 1996 09:13:43 +0200
- Organization: Kodak AG Germany, OI PE&D
- Message-ID: <31749A27.3949@ag01.kodak.COM>
- References: <316BF0C5.1FE1@condat.de> <RMARTIN.96Apr11113222@rcm.oma.com>
- <4kjfrh$28g@Starbase.NeoSoft.COM> <RMARTIN.96Apr16161415@rcm.oma.com>
- NNTP-Posting-Host: kagcpd10.ag01.kodak.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.01 (X11; I; HP-UX A.09.05 9000/715)
-
- Robert C. Martin wrote:
- > There is nothing about C++ that encourages programmers to perform
- > a great deal more allocation and de-allocation of memory. Some
- > popular styles advocate this, but they advocate it in C++ as well as
- > other languages.
- >
- > Also. If you use a programming style that is heavily weighted towards
- > dynamic memory allocation, you can prefent fragmentation and heap
- > delays by using non-deterministic heaps.
-
- If you really want to use the powers of C++ instead of using C++ as a
- better C you have more memory allocation and deallocation. In C you very
- often handle pointers and care about when to free the memory associated
- with that memory. In C++ you always copy memory to other objects with
- constructors or operators, because you use class objects like other
- integral types without thinking too much (you could, but you don't want
- to because the program is more readable then :). You even have a lot of
- memory allocation and deallocation by using arguments passed by value or
- by the compiler using temporaries. I was astonished, when I checked the
- code produced by my Microtec C++ 4.x, allthough when I thought about it,
- there was no other way to handle that.
-
- In my special case I built a menu system based on an own curses
- implementation on pSOS. With the old C version I passed pointers to some
- structures to the menu library functions. In the C++ version I build a
- menu by adding menu items to a menu object, which causes many memory
- copy, allocation and deallocation calls (not to give the CPU any chance
- I even used a String class instead of char *'s). The other drawback is
- that with the old system I could hold the text for the menu text in ROM
- only (by declaring it const), but with C++ I have to copy it using e.g.
- the operator+= or some constructor, and even the type specifier const
- isn't a guarantee for beeing allocated in a readonly memory (ROM on
- embedded systems, readonly sections e.g. on UNIX), it just says, the
- variable cann only be initialized, but not changed by an assignement
- operator.
-
- Roman
-
- --
- Roman Fietze (Mail Code 5023) Kodak AG Stuttgart/Germany
- http://www.kodak.com fietze@kodak.COM
-